<template>
	<view class="content">
		<mSidebar title="当前进度">
			<view class="row">
				<m-steps v-for="(item, index) in wrapRecordList" 
					:item='item' 
					:key="index" 
					:index='index' 
					:activity= 'activity' 
					date='leaveApprovalTime'>
					<text slot="status">{{item.leaveApprovalRecord}}</text>
				</m-steps>
			</view>
		</mSidebar>
	</view>
</template>

<script>
	import mSidebar from "../../components/m-sidebar/m-sidebar.vue"
	import mSteps from '../../components/m-steps/m-steps.vue'
	import * as api from '../config/api.js'
	import { timestampToTime } from '../utils/timeToTime.js'
	export default {
		components: {
		    mSidebar,
		    mSteps
		},
		data(){
			return{
				// 当前进度，显示亮球,建议默认显示最新进度
				activity: 0,
				// 流程数组
				wrapRecordList:"",
			}
		},
		onLoad(option){
			let id = option.id
			let that = this
			api.getFurrentFlowApi(id,{
				data:{},
				success:res=>{
					// console.log(res)
					if(res.code == 200){
						let list = res.data;
						for(var i = 0 ; i < list.length; i++){
							list[i].leaveApprovalTime = timestampToTime(list[i].leaveApprovalTime)
						}
						console.log(list)
						that.wrapRecordList = list
					}else if(res.code == 500){
						uni.showToast({
							title:"暂无数据",
							icon:"none"
						})
					}else{
						uni.showToast({
							title:"请求失败",
							icon:"none"
						})
					}
					
				},
				fail:err=>{
					// console.log(err)
					uni.showToast({
						title:"网络延迟",
						icon:"none"
					})
				}
			})
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 40rpx;
		.row {
			padding: 24rpx 0;
		}
	}
</style>